﻿Public Class frmBaseView

    ''' <summary>
    ''' Thuộc tính lưu tiêu đề của form khi được hiển thị
    ''' </summary>
    ''' <remarks>Nguyễn Huy Thường added on 08/06/2012</remarks>
    Private m_Title As String
    Public Property Title() As String
        Get
            Return m_Title
        End Get
        Set(ByVal value As String)
            m_Title = value
        End Set
    End Property

    ''' <summary>
    ''' Thuộc tính lưu loại báo cáo sẽ được hiển thị
    ''' </summary>
    ''' <remarks>Nguyễn Huy Thường added on 08/06/2012</remarks>
    Private m_ReportType As clscommon.ReportType
    Public Property ReportType() As clscommon.ReportType
        Get
            Return m_ReportType
        End Get
        Set(ByVal value As clscommon.ReportType)
            m_ReportType = value
        End Set
    End Property

    ''' <summary>
    ''' Thuộc tính lưu nguồn dữ liệu để fill vào report
    ''' </summary>
    ''' <remarks>Nguyễn Huy Thường added on 08/06/2012</remarks>
    Private m_DataSource As DataTable
    Public Property DataSource() As DataTable
        Get
            Return m_DataSource
        End Get
        Set(ByVal value As DataTable)
            m_DataSource = value
        End Set
    End Property

    ''' <summary>
    ''' Thuộc tính lưu đối tượng lớp BL
    ''' </summary>
    ''' <remarks>Nguyễn Huy Thường added on 08/06/2012</remarks>
    Private m_BusinessObject As BL.clsBLBase
    Public Property BusinessObject() As BL.clsBLBase
        Get
            Return m_BusinessObject
        End Get
        Set(ByVal value As BL.clsBLBase)
            m_BusinessObject = value
        End Set
    End Property

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Try
            Me.Close()
        Catch ex As Exception
            clscommon.ShowException(ex.Message)
        End Try
    End Sub

    Private Sub btnView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnView.Click
        Try
            Me.Hide()
            With BusinessObject
                If ReportType = clscommon.ReportType.AvailableItem Then
                    .dsFMS.AvailableItem.Clear()
                    .FillReport(.dsFMS.AvailableItem.TableName)
                    DataSource = .dsFMS.AvailableItem
                    Title = My.Resources.AvailableItemListTitle
                ElseIf ReportType = clscommon.ReportType.AllItem Then
                    .dsFMS.AllItem.Clear()
                    .FillReport(.dsFMS.AllItem.TableName)
                    DataSource = .dsFMS.AllItem
                    Title = My.Resources.AllItemListTitle
                End If
            End With
            Dim showReport As New frmReport
            With showReport
                .ReportType = ReportType
                .DataSource = DataSource
                .Title = Title
                .Owner = Me.Owner
                .ShowDialog()
            End With
            Me.Close()
        Catch ex As Exception
            clscommon.ShowException(ex.Message)
        End Try
    End Sub
End Class